<script setup lang="ts">
import { onBeforeMount } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

onBeforeMount(() => {
  router.beforeEach((to, from, next) => {
    let BarWheelMachineList = localStorage.BarWheelMachineList ? JSON.parse(localStorage.BarWheelMachineList) : null
    try {
      const doulun = to.matched.find(item => item.path.includes('doulun'))
      // console.log('App------------>', doulun)
      
      if (doulun && doulun.meta) {
        const target = BarWheelMachineList.find(
          item => item.menuId === doulun.meta.id
        )

        // console.log(target, ",,,,,,");
        target && (localStorage.BarWheelMachineCode = target.code)
      }
    } catch (error) {
      console.log('app.vue', error)
    }
    next()
  })
})
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup

</script>

<template>
  <router-view />
</template>

<style scoped>
.logo {
  height: 6em;
  padding: 1.5em;
  will-change: filter;
}

.logo:hover {
  filter: drop-shadow(0 0 2em #646cffaa);
}

.logo.vue:hover {
  filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
